<?php

/*
 * Action 5$
 * 
 * +1 Card
 * +1 Action
 * +1 Coin
 * Trash a card from your hand.
 *
 */

class JunkDealer extends Card implements iAction, iKingdom, iDarkAges {

    public function __construct() {
        parent::__construct("Junk Dealer", 5);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "+1 Coin",
            "Trash a card from your hand.");
    }

    public function play(Game $game, $isRealCard) {
        $game->addActions(1);
        $game->addMoney(new Price(1));
        $drawed_cards = $game->drawCards(1);

        ScreenDisplay::addScreenMessage($game, true, "get +1 action, +1$  and draw " . nicePrint($drawed_cards), "get +1 action, +1$ and draws " . sizeof($drawed_cards) . " cards");
        
        $playhand = $game->getPlayHand();
		
        if (sizeof($playhand) > 0) {

			$playhand = getUniqueCards($playhand);
			if (sizeof($playhand) > 1) {
				$output = MySocket::GetUserReply($game, Input_ChooseOne, $playhand, 1, 1, null, "Choose a card to trash");
				$old_card_name = $output[0];
			}
			else {
				$old_card_name = $playhand[0];
			}
            $old_card = $game->moveCardFromPileToPile($old_card_name, PlayHand, Trash);
            ScreenDisplay::addScreenMessage($game, true, "trash " . nicePrint($old_card), "trashes " . ScreenDisplay::$LMSG);
        }
        else {
            ScreenDisplay::addScreenMessage($game, true, "trash nothing", "trashes nothing");
        }
		$game->cardActionFinished();
        return true;
        
    }

}

?>